<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
/* <![CDATA[ */

table, td
{
    border-color: #666;
    border-style: solid;
}
table, th
{
    border-color: #666;
    border-style: solid;
}

table
{
    border-width: 0 0 1px 1px;
    border-spacing: 0;
    border-collapse: collapse;
}
 
td
{
    margin: 0;
    padding: 4px;
    border-width: 1px 1px 0 0;
}
th
{
    margin: 0;
    padding: 4px;
    border-width: 1px 1px 0 0;
}

/* ]]> */
</style>
<link type="text/css" href="/css/start/jquery-ui-1.8.21.custom.css" rel="Stylesheet" />	
<link rel="stylesheet" href="/js/chosen/chosen.css" />

<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.21.custom.min.js"></script>

<script>
	$(function() {
		$( "#shift_date" ).datepicker({ dateFormat: "yy-mm-dd",firstDay: 1 });
	});
	</script>
    
    
</head>
<body style="font-family:Arial, Helvetica, sans-serif">
<?php

date_default_timezone_set("Australia/Melbourne");
$idManager = 0;

if(!$_POST){
	$idManager = $this->idMgr;
	}
else{
	$idManager = $_POST["id_manager"];	
	}	

$caseID = "";
$idStaff = "";
$shopCode = "";
$shiftDate = "";

$manShiftBeginHour = 0;
$manShiftBeginMin = 0;
$manShiftEndHour = 0;
$manShiftEndMin = 0;

$shiftBeginHour = 0;
$shiftBeginMin = 0;
$shiftEndHour = 0;
$shiftEndMin = 0;

$firstBreak = 0;
$secondBreak = 0;
$shiftHours = 0;
$actualHours = 0;

$errFlag = false;

$preLoad = $this->preLoad;
if(!empty($preLoad)){
//the case is create according the system problem list 	
	$caseID = "CA".trim($preLoad['id_sheet']);
	$shopCode = trim($preLoad['shop_head']);
	$shiftDate = date("Y-m-d",(int)$preLoad['confirm_shift_begin']);
	
	$manShiftBeginHour = date("H",(int)$preLoad['confirm_shift_begin']);
	$manShiftBeginMin = date("i",(int)$preLoad['confirm_shift_begin']);
	
	$manShiftEndHour = date("H",(int)$preLoad['confirm_shift_end']); 
	$manShiftEndMin = date("i",(int)$preLoad['confirm_shift_end']);
	
	$shiftBeginHour = ((int)$preLoad['on_duty'])?date("H",(int)$preLoad['on_duty']):'-'; 
	$shiftBeginMin = ((int)$preLoad['on_duty'])?date("i",(int)$preLoad['on_duty']):'-';  

	$shiftEndHour = ((int)$preLoad['off_duty'])?date("H",(int)$preLoad['off_duty']):'-'; 
	$shiftEndMin = ((int)$preLoad['off_duty'])?date("i",(int)$preLoad['off_duty']):'-'; 
	
	$firstBreak = $preLoad['break_time'] /60;
	
	if((($preLoad['confirm_shift_end'] - $preLoad['confirm_shift_begin']) >= 18000) && $firstBreak == 0){	
	
	$firstBreak = 30;	
	
	}
	if(($preLoad['confirm_shift_end'] - $preLoad['confirm_shift_begin']) >= 32400 && $firstBreak < 60){		
	$secondBreak = 30;
	}
	
// ACTUAL HOURS

if( ($preLoad["confirm_shift_begin"] == $preLoad["confirm_shift_end"]) || $preLoad["on_duty"] == null || $preLoad["off_duty"] == null  ) {
	$actualHours = 0;
	}
else{	

	
	$manShiftBegin = $preLoad["confirm_shift_begin"];
	$manShiftEnd = $preLoad["confirm_shift_end"];
	$manAllo = $manShiftEnd - $manShiftBegin;
	
	$actBegin = $preLoad["on_duty"];
	$actEnd = $preLoad["off_duty"];
	
	if($manShiftBegin!= null && $actBegin!="" && ( $actBegin > ($manShiftBegin + 300))){

	$manShiftBegin = $actBegin;
	}
	
	if($actEnd!="" && $manShiftEnd!= null && ( ($actEnd + 300) < $manShiftEnd) ){
							
	$manShiftEnd = $actEnd;		
							
	}
	
	
	$actualHours = round(($manShiftEnd - $manShiftBegin - $firstBreak*60)/3600,2);
	
	
	if($manAllo >=34200){
		$actualHours -= 0.5;
		}
	}

// Shifted Hours

    if( $preLoad["confirm_shift_begin"] != $preLoad["confirm_shift_end"] ) {
	
	$shiftHours = round(($preLoad["confirm_shift_end"] - $preLoad["confirm_shift_begin"] - $firstBreak*60)/3600,2); 
	
	if(($preLoad["confirm_shift_end"] - $preLoad["confirm_shift_begin"]) >=34200){
		
		$shiftHours -= 0.5;
		}
	
	} 
		
	}
else{
// case created by manager manually 	

		
$caseID = "SC".date("U").mt_rand(0,9);
	
}	

//var_dump($this->preLoad);

?>
<h1> Create Case: </h1>
<form action="/rosteraudit/confirm-create-case" method="post" enctype="multipart/form-data" name="form1" id="form1">
<table width="600" cellspacing="1" cellpadding="5" style="text-align:left; font-size:13px;">

  <tr>
    <th colspan="2" scope="row" style="width:350px;" >Case ID: <?php
    
    $attCase = new Model_DbTable_Roster_Attncase();
    if($attCase->existCaseID($caseID)){
		$errFlag = true;
	?>
	 <span style="color:#F00">CASE EXIST,DO NOT PROCEED</span>
	<?php }?>   
   
</th>
    <td><input name="id_manager" type="hidden" value="<?php echo $idManager;?>" />
      <input name="case_id" type="text" id="case_id" value="<?php echo $caseID;?>" readonly="readonly" /> </td>
  </tr>
  <tr>
    <th colspan="2" scope="row" >Choose Staff Name</th>
    <td>
    <select name="staff_name" data-placeholder="Staff Name" class="chzn-select" style="width:240px" id="staff_name">
      <option value=""></option>
      <?php foreach($this->stList as $k => $v) {?>
      <option value="<?=$v["id"]?>" 
      <?php
      if($v["id"]==$preLoad["id_staff"]){
		  
		  echo 'selected = "selected"';
		  }
	  ?>
      >
        <?=ucwords($v["ni"])?>
        .
        <?=chr($v["il"]+64)?> ( <?=ucwords(Model_EncryptHelper::getSslPassword($v["n"]))?> )
        </option>
      <?php } ?>
    </select
    
    
      ><br /></td>
  </tr>
  <tr>
    <th colspan="2" scope="row">Shifted Shop</th>
    <td>
    <?php
    if(!empty($preLoad)){
	?>
      <input type="text" name="shop_code" id="shop_code" value="<?php echo $shopCode;?>" />
      <br />
    <?php }
	else{
	?>	  
      <select name="shop_code">
      <option value="0" selected="selected" >-Please Select-</option>
        <option value="ADPC">ADPC</option>
        <option value="BBPC">BBPC</option>
        <option value="BHPC">BHPC</option>
        <option value="BSPC">BSPC</option>
        <option value="BSIC">BSIC</option>
        <option value="BSXP">BSXP</option>
        <option value="CBPC">CBPC</option>
        <option value="CLPC">CLPC</option>
        <option value="CLIC">CLIC</option>
        <option value="CSIC">CSIC</option>
        <option value="DCIC">DCIC</option>
        <option value="EPPC">EPPC</option>
        <option value="FGIC">FGIC</option>
        <option value="HPIC">HPIC</option>
        <option value="KCPC">KCPC</option>
        <option value="NLPC">NLPC</option>
        <option value="PMPC">PMPC</option>
        <option value="PMIC">PMIC</option>
        <option value="SLIC">SLIC</option>
        <option value="WBPC">WBPC</option>
        <option value="WBIC">WBIC</option>
        <option value="WGPC">WGPC</option>
        <option value="WGIC">WGIC</option>
        <option value="WLIC">WLIC</option>
      </select>
     <?php } ?> 
      </td>
  </tr>
   <tr>
    <th colspan="2" scope="row">Staff Shifted Date</th>
    <td><input name="shift_date" type="text" id="shift_date" value="<?php echo $shiftDate;?>" readonly="readonly" /></td>
  </tr>
  <tr>
    <th rowspan="2" scope="row" style="width:150px;">Manager Allocated Shift</th>
    <th scope="row" style="width:100px;">Shift Begin</th>
    <td><input name="man_shift_begin_hour" type="text" id="man_shift_begin_hour" style="width:50px;" value="<?php echo $manShiftBeginHour?>" readonly="readonly" />
      :
      <input name="man_shift_begin_min" type="text" id="man_shift_begin_min" style="width:50px;"  value="<?php echo $manShiftBeginMin?>" readonly="readonly" /> 
      <i style="font-size:10px;">(read only)</i></td>
  </tr>
  <tr>
    <th scope="row">Shift End</th>
    <td><input name="man_shift_end_hour" type="text" id="man_shift_end_hour" style="width:50px;" value="<?php echo $manShiftEndHour?>" readonly="readonly"  />
      :
      <input name="man_shift_end_min" type="text" id="man_shift_end_min" style="width:50px;"  value="<?php echo $manShiftEndMin?>" readonly="readonly"/>
      <i style="font-size:10px;">(read only)</i></td>
  </tr> 
    <tr>
    <th rowspan="2" scope="row">System  Recorded Login/Logout</th>
    <th scope="row">Login Record</th>
    <td><input name="act_shift_begin_hour" type="text" id="act_shift_begin_hour" style="width:50px;" value="<?php echo $shiftBeginHour?>" readonly="readonly" />
      :
      <input name="act_shift_begin_min" type="text" id="act_shift_begin_min" style="width:50px;" value="<?php echo $shiftBeginMin?>" readonly="readonly" />
      <i style="font-size:10px;">(read only)</i></td>
  </tr>
    <tr>
      <th scope="row">Logout Record</th>
    <td><input name="act_shift_end_hour" type="text" id="act_shift_end_hour" style="width:50px;" value="<?php echo $shiftEndHour?>" readonly="readonly" />
      :
      <input name="act_shift_end_min" type="text" id="act_shift_end_min" style="width:50px;" value="<?php echo $shiftEndMin?>" readonly="readonly" />
      <i style="font-size:10px;">(read only)</i></td>
  </tr>
    <tr>
      <th rowspan="2" bgcolor="#BBFFBB" scope="row">Lauch Claim <br />
      (Input Full Shift HERE)</th>
      <th bgcolor="#BBFFBB" scope="row">Propose Shift Begin<span style="color:#800; font-weight:bold">*</span></th>
      <td bgcolor="#BBFFBB"><input name="pro_shift_begin_hour" type="text" id="pro_shift_begin_hour" style="width:50px;" value="00" class="modify" />
        :
      <input name="pro_shift_begin_min" type="text" id="pro_shift_begin_min" style="width:50px;" value="00"  class="modify"  /></td>
    </tr>
    <tr>
      <th bgcolor="#BBFFBB" scope="row">Propose Shift End<span style="color:#800; font-weight:bold">*</span></th>
      <td bgcolor="#BBFFBB"><input name="pro_shift_end_hour" type="text" id="pro_shift_end_hour" style="width:50px;" value="00"  class="modify"  />
        :
      <input name="pro_shift_end_min" type="text" id="pro_shift_end_min" style="width:50px;" value="00"  class="modify"   /></td>
    </tr>
    <tr>
    <th rowspan="2" scope="row">Break Time<br />
      <span style="font-size:10px;">( Set Second Break to 0 If Only Have One Break )</span></th>
    <th scope="row">First Break<span style="color:#800; font-weight:bold">*</span></th>
    <td><input name="first_break" type="text" id="first_break" style="width:50px;" value="<?php echo $firstBreak;?>" readonly="readonly" />
      (Mins)<i style="font-size:10px;">(read only)</i></td>
  </tr>
    <tr>
      <th scope="row">Second Break<span style="color:#800; font-weight:bold">*</span></th>
      <td><input name="second_break" type="text" id="second_break" style="width:50px;" value="<?php echo $secondBreak;?>" readonly="readonly" />
        (Mins)<i style="font-size:10px;">(read only)</i></td>
    </tr>
    <tr>
      <th colspan="3" align="center" scope="row">Provide Evidence<br /></th>
    </tr>
    <tr>
      <td colspan="3" bgcolor="#FF6699"><ul>
        <li>You should provide OUR DVR Footage Screen Shot With Correct Time  on the Image</li>
        <li>Please provide bright and clear image, please rotate the image if it is upside down</li>
        <li>&quot;Microsoft Word&quot; should be a easy tool you have problem edit the Image</li>
        <li>If there are more than One People in the image,please point out our staff</li>
        <li>If footage can not be provided,please proivde other evidences and detail explaination <br />      
          <br />
        </li>
      </ul></td>
    </tr>
    <tr>
      <th colspan="2" scope="row">Footage for Shift Begin<br />
        <span style="font-size:10px;"> (.zip file,.doc .docx file,.jpg file,check your footage file size, 2MB max)</span></th>
      <td><label for="footage_on_duty"></label>
      <input type="file" name="footage_on_duty" id="footage_on_duty" /></td>
    </tr>
    <tr>
      <th colspan="2" scope="row">Footage for Shift End</th>
      <td><input type="file" name="footage_off_duty" id="footage_off_duty" /></td>
    </tr>
    <tr>
      <th colspan="2" scope="row">Offline APOS Invoice For Shift Begin<br />
<span style="font-size:10px;"> (Leave blank if the staff missing Off Duty Record )</span></th>
      <td><label for="apos_invoice_on_duty"></label>
      <input type="text" name="apos_invoice_on_duty" id="apos_invoice_on_duty" /></td>
    </tr>
    <tr>
      <th colspan="2" scope="row">Offline APOS Invoice For Shift End<br /><span style="font-size:10px;"> (Leave blank if the staff missing On Duty Record )</span></th>
      <td><input type="text" name="apos_invoice_off_duty" id="apos_invoice_off_duty" /></td>
    </tr>
    <tr>
      <th colspan="3" scope="row">Reason why I can not provide any footage</th>
    </tr>
    <tr>
      <th colspan="3" scope="row"><label for="reason_missing_footage"></label>
      <textarea name="reason_missing_footage" id="reason_missing_footage" cols="90" rows="5"></textarea></th>
    </tr>
    <tr>
      <th colspan="3" scope="row">Detail explaination (no words limits)</th>
    </tr>
    <tr>
      <th colspan="3" scope="row"><textarea name="detail_explain" id="detail_explain" cols="90" rows="5"></textarea></th>
    </tr>
    <tr>
      <th colspan="3" align="center" scope="row"><p><br />
      </p>
      <input type="submit" name="button" id="button" value="Next" <?php echo ($errFlag)?'disabled = "disabled"':''; ?> /></th>
    </tr>   
      
</table>
</form>
<script src="/js/chosen/chosen.jquery.js" type="text/javascript"></script>
  <script type="text/javascript"> 
    var config = {
      '.chzn-select': {allow_single_deselect:true},
    }
    for (var selector in config) {
      $(selector).chosen(config[selector]);
    };
  </script>
<script>
$('.modify').change(function(){
	//check 4 place 
	
	
	});

</script>  
<div style=" font-size:10px; color:#666;float:left;" >Developer:Norman,Date:2015-01-27</div>
</body>
</html>
